﻿package idv.cjcat.emitter.fields {
	use namespace engine;
	
	import idv.cjcat.emitter.*;
	import idv.cjcat.emitter.ds.*;
	import idv.cjcat.emitter.geom.*;
	
	/**
	 * Uniform field.
	 */
	public class UniformField extends Field {
		
		public var x:Number;
		public var y:Number;
		
		public function UniformField(x:Number = 0, y:Number = 0.4) {
			this.x = x;
			this.y = y;
		}
		
		override public function getMotionData2D(pd:ParticleData):MotionData2D {
			
			return MotionData2DPool.get(x, y);
		}
		
		
		//XML
		//------------------------------------------------------------------------------------------------
		
		override public function toXML():XML {
			var xml:XML = super.toXML();
			xml.@type = FieldType.UNIFORM;
			xml.@x = x.toString();
			xml.@y = y.toString();
			
			return xml;
		}
		
		override public function parseXML(xml:XML):void {
			super.parseXML(xml);
			
			x = parseFloat(xml.@x);
			y = parseFloat(xml.@y);
		}
		
		//------------------------------------------------------------------------------------------------
		//XML
	}
}